package com.crm.mapper.system;

import com.crm.aonnation.AutoFill;
import com.crm.dto.QueryDictDataDto;
import com.crm.enumeration.OperationType;
import com.crm.pojo.DictData;
import com.crm.pojo.Referredsubject;
import com.crm.vo.ActivityStatusVO;
import com.crm.vo.ChannelTypeVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface DictDataMapper {

    /**
     * 分页查询
     * @param dto
     * @return
     */
    Page<DictData> page(QueryDictDataDto dto);

    @AutoFill(value = OperationType.INSERT)
    @Insert("INSERT INTO tb_dict_detail(dict_id, dict_label, dict_value, status, dsc, is_default, create_time, update_time, create_by, update_by, dict_sort) " +
            " values (#{dictId},#{dictLabel},#{dictValue},#{status},#{remark},#{isDefault},#{createTime},#{updateTime},#{createBy},#{updateBy},#{dictSort})")
    void add(DictData dictData);
@Select("select * from tb_dict_detail where dict_id=#{dictId}")
    List<DictData> searchByDictId(Integer dictId);

    @Select("  select dd.*,d.dict_type from tb_dict_detail dd left join tb_dict d on dd.dict_id=d.id where dd.dict_code=#{dictCode} ")
    DictData getByDictCode(Integer dictCode);

    @AutoFill(value = OperationType.UPDATE)
    void update(DictData dictData);

    List<DictData> searchByDictCodes(List<Integer> dictCodes);

    @Delete("delete from tb_dict_detail where dict_code=#{dictCode}")
    void delete(Integer dictCode);


    //统一数据字典
    @Select("select * from tb_dict_detail where dict_id=#{dictId}")
    List<Referredsubject> getByid(Integer dictId);
}
